<?php
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hypref_mall
 * contact  hyperf_mall@163.com
 */
namespace App\Params;

class AuthLoginDataParams
{
    /**
     * 用户id
     * @var int
     */
    protected $id = 0;

    /**
     * 用户名
     * @var string
     */
    protected $username = null;

    /**
     * 密码
     * @var string
     */
    protected $password = null;

    public function __construct($data)
    {
        foreach ($data as $key => $value) {
            $this->$key = $value;
        }
    }

    /**
     * @return string
     */
    public function getUsername(): ?string
    {
        return $this->username;
    }

    /**
     * @return string
     */
    public function getPassword(): ?string
    {
        return $this->password;
    }

    /**
     * @return int
     */
    public function getId(): int
    {
        return $this->id;
    }

    /**
     * Notes:获取去除敏感信息的类属性值
     * @return array
     */
    public function getData(): array
    {
        $data = get_object_vars($this);
        //去除敏感信息
        unset($data['password']);
        return get_object_vars($this);
    }

}
